home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mc51bugs.zip / Q32771 < prev    next >
Text File  |  1988-07-29  |  2KB  |  86 lines

  1. Q32771 matherr Gives Null Pointer in Multithreaded Program
  2. C Compiler
  3. 5.10   | 5.10
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.    Making an assignment to the exception structure in a user-defined
  8. matherr function will cause the "R6001: Null pointer assignment" error
  9. to be generated when using the multithread statically linked C
  10. run-time library LLIBCMT.LIB.
  11.    Microsoft has confirmed this to be a problem in Version 5.10 of the
  12. C compiler. We are researching this problem and will post new
  13. information as it becomes available.
  14.  
  15.  
  16. More Information:
  17.    The program below demonstrates the problem by generating a numeric
  18. error, which causes the user-defined matherr function to be called.
  19.    Compile the example with the following command line:
  20.  
  21.    cl /Alfw file.c /link llibcmt doscalls/NOE/NOD;
  22.  
  23.    The following is the sample program:
  24.  
  25. #define INCL_BASE
  26. #include <malloc.h>
  27. #include <os2.h>
  28. #include <math.h>
  29.  
  30. void main(int,char**);
  31. void main2(void);
  32. int  matherr(struct exception*);
  33.  
  34. HSEM sem=0L;
  35.  
  36.  void main(argc,argv)
  37.  int argc;
  38.  char *argv[];
  39.  {
  40.     int handtype,flword;
  41.     unsigned thread;
  42.     char *arglist;
  43.  
  44.     thread = _beginthread(main2,malloc(16*1024),16*1024,arglist);
  45.     DosSemSetWait(&sem,-1L);
  46. }
  47.  
  48.  void main2()
  49. {
  50.    double a;
  51.    a=pow(10.0,500.0) ;
  52.    DosSemClear(&sem);
  53. }
  54.  
  55.  
  56.  matherr(x)
  57.  struct exception *x;
  58. {
  59.    switch(x->type)
  60.    {
  61.       case DOMAIN:
  62.       case SING:
  63.          printf("Invalid function parameter");
  64.          break;
  65.       case OVERFLOW:
  66.          printf("Numeric overflow");
  67.          break;
  68.       case UNDERFLOW:
  69.          printf("Numeric underflow");
  70.          break;
  71.       case TLOSS:
  72.       case PLOSS:
  73.          printf("Numeric loss of accuracy");
  74.          break;
  75.       default:
  76.          printf("Numeric error");
  77.          break;
  78.    }
  79.    x->retval = 0.0;/* This assignment causes the error */
  80.    return(1.0);
  81. }
  82.  
  83.  
  84. Keywords:  buglist5.10
  85. Updated  88/07/29 14:28
  86.